require 'rubygems'
require 'rubygems/package_task'
require 'cucumber'
require 'cucumber/rake/task'
require 'rake/testtask'
require 'fileutils'

spec = Gem::Specification.new do |s|
  s.platform = Gem::Platform::RUBY
  s.summary = "Sirius Ruby client"
  s.name = "sirius-client-win32"
  s.version = File.read('VERSION').chomp
  s.requirements = "none"
  s.files = FileList["lib/**/*.rb", "Rakefile"]
  s.homepage = "http://github.com/mkolisnyk/Sirius"
  s.description = "The client for Sirius system"
  s.authors="Myk Kolisnyk"
  s.email="kolesnik.nickolay@gmail.com"
end

task :clean do |t|
  FileUtils.rm_r 'pkg', :force => true
end

task :rubocop do |t|
  includes = Dir['lib/**/*']
  excludes = Dir['lib/sirius/win32/core/**/*']
  
  file_list = (includes - excludes ).reject {|fn| File.directory?(fn)}   
  
  file_list.each do |path|
    sh "call rubocop -c .rubocop.yml -e #{path}"
  end
end

Rake::TestTask.new(:install_test) do |task|
  task.name = 'install_test'
  task.libs << "test"
  task.test_files = FileList['tests/install/**/*.rb']
  task.verbose = true
end

Gem::PackageTask.new(spec) do |pkg|
end

Cucumber::Rake::Task.new(:test) do |t|
  t.cucumber_opts = "tests/features --format pretty --guess"
end

task :push => [:package] do |t| 
  sh "call gem push -V pkg/#{spec.name}-#{spec.version}.gem"
end

task :all => [:clean,:rubocop,:package,:install_test]